package com.ruoyi.operateTraining.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.mateDevice.domain.DeviceRepairModel;
import com.ruoyi.operateTraining.domain.InternalAuditPlan;
import com.ruoyi.operateTraining.domain.InternalAuditPlanModel;
import com.ruoyi.operateTraining.domain.InternalAuditSign;
import com.ruoyi.operateTraining.domain.InternalAuditSignModel;
import com.ruoyi.operateTraining.domain.TrainingEvaluate;
import com.ruoyi.operateTraining.domain.TrainingPlan;
import com.ruoyi.operateTraining.domain.TrainingPlanModel;
import com.ruoyi.operateTraining.domain.TrainingSign;
import com.ruoyi.operateTraining.domain.TrainingSignModel;
import com.ruoyi.operateTraining.mapper.TrainingMapper;
import com.ruoyi.operateTraining.service.TrainingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author
 * @Version 1.0
 */
@Service
public class TrainingServiceImpl implements TrainingService {

    @Autowired
    private TrainingMapper trainingMapper;

    @Override
    public int addTrainingPlan(TrainingPlan trainingPlan) {
        trainingPlan.setDeptId(SecurityUtils.getDeptId());
        int a = trainingMapper.addTrainingPlan(trainingPlan);
        if (trainingPlan.getTrainingPlanModels().size() != 0) {
            for (TrainingPlanModel trainingPlanModel : trainingPlan.getTrainingPlanModels()) {
                trainingPlanModel.setTrainingPlanId(trainingPlan.getTrainingPlanId());
                trainingMapper.addTrainingPlanModel(trainingPlanModel);
            }
        }
        return a;

    }

    @Override
    public List<TrainingPlan> selectTrainingPlanList(TrainingPlan trainingPlan) {
        return trainingMapper.selectTrainingPlanList(trainingPlan);
    }

    @Override
    public int addTrainingSign(TrainingSign trainingSign) {
        trainingSign.setDeptId(SecurityUtils.getDeptId());
        int a = trainingMapper.addTrainingSign(trainingSign);
        if (trainingSign.getTrainingSignModels().size() != 0) {
            for (TrainingSignModel trainingSignModel : trainingSign.getTrainingSignModels()) {
                trainingSignModel.setSignId(trainingSign.getSignId());
                trainingMapper.addTrainingSignModel(trainingSignModel);
            }
        } else {

        }
        return a;
    }

    @Override
    public int addTrainingEvaluate(TrainingEvaluate trainingEvaluate) {
        return trainingMapper.addTrainingEvaluate(trainingEvaluate);
    }

    @Override
    public List<TrainingSign> selectSignList(TrainingSign trainingSign) {
        return trainingMapper.selectSignList(trainingSign);
    }

    @Override
    public List<TrainingEvaluate> selectEvaluateList(TrainingEvaluate trainingEvaluate) {
        return trainingMapper.selectEvaluateList(trainingEvaluate);
    }

    @Override
    public int addInternalAuditSign(InternalAuditSign internalAuditSign) {
        internalAuditSign.setDeptId(SecurityUtils.getDeptId());
        int a = trainingMapper.addInternalAuditSign(internalAuditSign);
        if (internalAuditSign.getInternalAuditSignModels().size() != 0) {
            for (InternalAuditSignModel internalAuditSignModel : internalAuditSign.getInternalAuditSignModels()) {
                internalAuditSignModel.setInternalSignId(internalAuditSign.getInternalSignId());
                trainingMapper.addInternalAuditSignModel(internalAuditSignModel);
            }
        }
        return a;
    }

    @Override
    public int addInternalAuditPlan(InternalAuditPlan internalAuditPlan) {
        internalAuditPlan.setDeptId(SecurityUtils.getDeptId());
        int a = trainingMapper.addInternalAuditPlan(internalAuditPlan);
        if (internalAuditPlan.getInternalAuditPlanModels().size() != 0) {
            for (InternalAuditPlanModel internalAuditPlanModel : internalAuditPlan.getInternalAuditPlanModels()) {
                internalAuditPlanModel.setInternalId(internalAuditPlan.getInternalId());
                trainingMapper.addInternalAuditPlanMoel(internalAuditPlanModel);
            }
        }
        return a;
    }
}
